﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using OpenAPI.CommonLib;
using TEST;
using System.IO;
using System.Web.Script.Serialization;

namespace MvcRouteTest.Controllers
{
	public class ResultContent : ActionResult
	{
		public string Result { get; set; }

		public override void ExecuteResult(ControllerContext context)
		{
			ContentResult result = new ContentResult
			{
				//Content = "{\"queryCondition\": {\"guid\":\"\",\"queryIP\": \"192.169.1.1\",\"takeoffCity\": \"BJS\",\"arrivalCity\": \"HKG\",\"direction\": 0,\"platType\": 1,\"takeoffDate\": \"2014-02-03\",\"returnDate\": \"2014-02-23\",\"cabinSeatGrade\": 1,\"assignQuery\": \"\", \"travelType\": 0, \"adultNum\": 1, \"childNum\": 0,\"babyNum\": 0,\"passengerAge\": [],\"passengerType\":1,\"onlyQueryInLand\": 0,\"unionIndex\": 0,\"searchSegments\":[],\"vendorPref\":[]}}",
				Content = Result,
				ContentEncoding = Encoding.UTF8,
				ContentType = "application/json"
			};
			result.ExecuteResult(context);
		}
	}

	public class CustomerController : Controller
	{
		//
		// GET: /Customer/

		public ActionResult Index()
		{
			ViewBag.Controller = "Customer";
			ViewBag.Action = "Index";
			return View("ActionName");
		}
		public ActionResult List()
		{
			ViewBag.Controller = "Customer";
			ViewBag.Action = "List";
			return Redirect("/home/index");
		}
		public ViewResult Date()
		{
			DateTime date = DateTime.Now;
			ViewBag.date = date;
			ViewData["Time"] = date.ToShortDateString();
			return View(date);
		}
		[HttpPost]
		public ActionResult ZhongGuang()
		{
			string result = "";
			if (Request.InputStream != null)
			{
				using (Stream stream = Request.InputStream)
				{
					stream.Position = 0;
					StreamReader reader = new StreamReader(stream);
					result = reader.ReadToEnd();
					reader.Close();
				}
			}
			return new ResultContent() { Result = result??"测试" };
		}
	}
}
